package com.wc.AlgoOJ_train.train3_算法大礼包.c3_贪心.AG0401_光头强的加油;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/28 17:25
 * @description http://43.138.190.70:8888/p/AG0401
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 10010;
    static int[][] a = new int[N][2];
    static int n, l, p;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            a[n - i + 1][0] = sc.nextInt();
            a[n - i + 1][1] = sc.nextInt();
        }
        l = sc.nextInt();
        p = sc.nextInt();
        a[0][0] = l;
        a[0][1] = p;
        PriorityQueue<Integer> q = new PriorityQueue<>(Comparator.reverseOrder());

        int curOil = p;
        int ans = 0;

        // 需要排序
        Arrays.sort(a, 1, n + 1, Comparator.comparingInt(o -> -o[0]));

        for (int i = 0; i < n; i++) {
            a[i][0] = a[i][0] - a[i + 1][0];
            a[i][1] = a[i + 1][1];
        }

        for (int i = 0; i <= n; i++) {
            while (curOil < a[i][0] && !q.isEmpty()) {
                // 这里是将沿途中最大的油加上
                curOil += q.poll();
                ans++;
            }
            if (curOil >= a[i][0]) {
                curOil -= a[i][0];
                q.add(a[i][1]);
            } else {
                // 把所有油加上都回到不了这一个位置
                ans = -1;
                break;
            }
        }

        out.println(ans);
        out.flush();
    }

}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}